<template>
	<div v-loading="!isShow">
		<div class="zs-card-sm zs-space-bottom zs-layout-flex-row">
			<el-select v-model="biProjectCode" class="zs-select-md zs-space-right-sm" placeholder="项目名称"
				@change="changeProject()">
				<el-option v-for="item in projectList" :key="item.biProjectCode" :label="item.projectName"
					:value="item.biProjectCode" />
			</el-select>
		</div>
		<el-scrollbar class="db-content-height" v-if="isShow">
			<div class="db-content-cards">
				<!-- 财务-开办费 -->
				<FinanceKaiBanFei :permi="cardPermis[0]" :subjectType="4" :hideList="[]" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceKaiBanFei>
				<!-- 财务-利润率 -->
				<FinanceLiRunBiao :permi="cardPermis[1]" :subjectType="3" :hideList="[]" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceLiRunBiao>
				<!-- 财务-投入产出表 -->
				<FinanceTouRuChanChu :permi="cardPermis[2]" :subjectType="2" :hideList="[]" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceTouRuChanChu>
				<!-- 财务-资金来源占用表 -->
				<FinanceZiJinLaiYuanZhanYong :permi="cardPermis[3]" :hideList="[]" :biProjectCode="biProjectCode" :biProjectName="biProjectName" :yearmonth="yearmonth"> </FinanceZiJinLaiYuanZhanYong>
			</div>
		</el-scrollbar>

	</div>
</template>
<script setup>

import FinanceKaiBanFei from '@/views/Manage/Business/components/financeKaiBanFei.vue'
import FinanceLiRunBiao from '@/views/Manage/Business/components/financeLiRunBiao.vue'
import FinanceTouRuChanChu from '@/views/Manage/Business/components/financeTouRuChanChu.vue'
import FinanceZiJinLaiYuanZhanYong from '@/views/Manage/Business/components/financeZiJinLaiYuanZhanYong.vue'

import dbPublicApi from '@/api/dbPublic'

import { ref } from 'vue'
import { useRoute } from 'vue-router'
const route = useRoute().query
let biProjectCode = ref(route.biProjectCode)
const projectCode = ref(route.projectCode)
let biProjectName = ref('');
const cardPermis = route.cardPermis.split(',');
const updateDate = route.updateDate;
const tabPermi = route.tabPermi;
const yearmonth = ref()
// 获取商业数据更新日期 年月 用于数字月报筛选
const queryDataUpdateTime = async () => {
	await dbPublicApi.queryMonthsTimeApi().then(res => {
		let resData = res.data
		if (resData.code == 200) {
			yearmonth.value = resData.data
		}
	})
}

let isShow = ref(false)
let projectList = ref([])
const getList = () => {
	dbPublicApi.queryProjectPcApi({ dataTime: updateDate, resourceKey: tabPermi }).then((res) => {
		if (res.data.code == 200) {
			projectList.value = res.data.data
			let target = projectList.value.find(item => {
				return item.biProjectCode == biProjectCode.value;
			});
			biProjectName.value = target ? target.projectName : '';
		}
	})
}

const changeProject = async () => {
	isShow.value = false
	const index = projectList.value.findIndex(item => {
		return item.biProjectCode == biProjectCode.value
	})
	projectCode.value = projectList.value[index].projectCode;
	biProjectName.value = projectList.value[index].projectName;
	isShow.value = true
}

const init = async () => {
	await queryDataUpdateTime()
	isShow.value = false
	getList()
	isShow.value = true
}
init()


</script>

<style scoped lang="scss"></style>
